{
  "properties" : { },
  "id" : "a089a6e63ef04f42b130b65de01092a8",
  "script" : null,
  "groupId" : "5affd458495e4bf8a43e1f578f0ce3a9",
  "name" : "每日告警统计",
  "createTime" : 1727070957516,
  "updateTime" : 1726284154915,
  "lock" : "1",
  "createBy" : "ndmp",
  "updateBy" : "ndmp",
  "path" : "hourCount",
  "method" : "GET",
  "parameters" : [ ],
  "options" : [ ],
  "requestBody" : "",
  "headers" : [ ],
  "paths" : [ ],
  "responseBody" : "{\n    \"status\": 200,\n    \"message\": \"success\",\n    \"data\": [\n        {\n            \"color\": \"#EE1A1A\",\n            \"name\": \"紧急告警\",\n            \"value\": {\n                \"1\": \"\",\n                \"2\": \"\",\n                \"3\": \"\",\n                \"4\": \"\",\n                \"5\": \"\",\n                \"6\": \"\",\n                \"7\": \"\",\n                \"8\": \"\",\n                \"9\": \"\",\n                \"10\": \"\",\n                \"11\": \"\"\n            }\n        },\n        {\n            \"color\": \"#E19506\",\n            \"name\": \"重要告警\",\n            \"value\": {\n                \"1\": \"\",\n                \"2\": \"\",\n                \"3\": \"\",\n                \"4\": \"\",\n                \"5\": \"\",\n                \"6\": \"\",\n                \"7\": \"\",\n                \"8\": \"\",\n                \"9\": \"\",\n                \"10\": \"\",\n                \"11\": \"\"\n            }\n        },\n        {\n            \"name\": \"已确认\",\n            \"value\": {\n                \"number\": \"0\"\n            }\n        },\n        {\n            \"name\": \"已恢复\",\n            \"value\": {\n                \"number\": \"0\"\n            }\n        }\n    ]\n}",
  "description" : "",
  "requestBodyDefinition" : {
    "name" : "",
    "value" : { },
    "description" : "",
    "required" : false,
    "dataType" : "String",
    "type" : "",
    "defaultValue" : "",
    "validateType" : "",
    "error" : "",
    "expression" : "",
    "children" : [ ]
  },
  "responseBodyDefinition" : {
    "name" : "",
    "value" : { },
    "description" : "",
    "required" : false,
    "dataType" : "String",
    "type" : "",
    "defaultValue" : "",
    "validateType" : "",
    "error" : "",
    "expression" : "",
    "children" : [ ]
  }
}
================================
import java.time.LocalTime;
import java.time.LocalDateTime;
import java.util.LinkedHashMap;
import org.springblade.core.tool.api.R;

    nowHour = LocalTime.now().getHour();
    LinkedHashMap urgentObject = new LinkedHashMap();
    LinkedHashMap seriousObject = new LinkedHashMap();
    int confirmed = 0; // 24小时内已确认数量
    int restored = 0;// 24小时内已恢复数量
    List res = new ArrayList();
    //拿到紧急告警24小时数据
    for (item in range(0,nowHour - 1)) {
        LocalDateTime startTime = LocalDateTime.now().withHour(item).withMinute(0).withSecond(0).withNano(0);
        LocalDateTime endTime = startTime.plusHours(1);
        String setHour = String.valueOf(endTime.getHour());
        count = db.selectOne("""
            select sum   ( case when leve.level = 1 then 1 else 0 end )  urgrnt,
                   sum ( case when leve.level = 5 then 1 else 0 end ) serious
            from alarm_info info
            left join alarm_rule ru on ru.id = info.alarm_rule_id
            left join alarm_level leve on leve.level = ru.level
            where alarm_time > #{startTime} and alarm_time <= #{endTime}
        """)
        urgentObject.put(setHour, null == count ? 0 : count.urgrnt);
        seriousObject.put(setHour, null == count ? 0 : count.serious);

    }
    urgentColor = db.selectOne(""" select display_color from alarm_level where level = 1 """)
    seriousColor = db.selectOne(""" select display_color from alarm_level where level = 5 """)
    //紧急告警
    var urgentVo = {
        "color": urgentColor.displayColor,
        "name": "紧急告警",
        "value": urgentObject
    }
    //严重告警
    var seriousVo = {
        "color": seriousColor.displayColor,
        "name": "重要告警",
        "value": seriousObject
    }
    LocalDateTime nowTime = LocalDateTime.now();
    LocalDateTime localDateTime = nowTime.minusHours(24);

    confirmed = db.selectOne("""
        select count(*) number from alarm_info_history where CONFIRM_TIME between #{localDateTime} and #{nowTime}
    """)

    restored = db.selectOne("""
        select count(*) number from alarm_info where is_recovery = 0 and recovery_time between #{localDateTime} and #{nowTime}
    """)
    
    //已确认
    var confirmVo = {
        "name": "已确认",
        "value": confirmed
    }

    //已恢复
    var restoreVo = {
        "name": "已恢复",
        "value": restored
    }

    res.add(urgentVo);
    res.add(seriousVo);
    res.add(confirmVo);
    res.add(restoreVo);

    return res;